#include <avz.h>

using namespace AvZ;

void Script()
{
    OpenMultipleEffective('Q', AvZ::MAIN_UI_OR_FIGHT_UI); // 多次生效
    SetAdvancedPauseKey('Z');                             // 按 Z 键控制高级暂停

    SetZombies({
        ZOMBIE,
        POLE_VAULTING_ZOMBIE,
        FOOTBALL_ZOMBIE,
        DANCING_ZOMBIE,
        ZOMBONI,
        JACK_IN_THE_BOX_ZOMBIE,
        DIGGER_ZOMBIE,
        POGO_ZOMBIE,
        BUNGEE_ZOMBIE,
        LADDER_ZOMBIE,
        CATAPULT_ZOMBIE,
        GARGANTUAR,
        GIGA_GARGANTUAR,
    });

    SelectCards({
        ICE_SHROOM,
        M_ICE_SHROOM,
        COFFEE_BEAN,
        CHERRY_BOMB,
        DOOM_SHROOM,
        JALAPENO,
        SQUASH,
        SNOW_PEA,
        PUFF_SHROOM,
        TALL_NUT,
    });

    SetTime(-599, 1);
    pao_operator.autoGetPaoList();
    plant_fixer.start(TALL_NUT);
    plant_fixer.resetFixHp(8000 * 1 / 3);
    ice_filler.start({{3, 1}, {3, 2}, {3, 3}});

    Card(ICE_SHROOM, 5, 8);

    SetTime(291 - 373, 1);
    // w1 B/PSD 601
    pao_operator.pao({{4, 9}, {4, 9}});
    Delay(110);
    pao_operator.pao({{4, 9}, {2, 8.05}});

    SetTime(602 - 100 - 198);
    Card(COFFEE_BEAN, 5, 8);

    SetTime(-95, 2);
    // w2 IPP-PP 1738
    pao_operator.pao(4, 9);
    SetTime(510 - 376);
    pao_operator.pao(1, 7.4125);
    SetTime(1538 - 373);
    pao_operator.pao({{2, 8.5375}, {4, 8.5375}});

    SetTime(1538 + 210 - 100 - 198);
    SetPlantActiveTime(ICE_SHROOM, 298);
    ice_filler.coffee();

    SetTime(513);
    Card(PUFF_SHROOM, 1, 9);
    Delay(751);
    Card(PUFF_SHROOM, 2, 9);
    SetTime(1738 + 10 - 266 - 147);
    Shovel({{1, 9}, {2, 9}});

    // w3 I3PPDD-PP 1738
    SetTime(410 - 373, 3);
    pao_operator.pao({{2, 8.525}, {4, 8.525}});
    Delay(212);
    pao_operator.pao({{1, 7.65}, {4, 7.65}});
    SetTime(1538 - 373);
    pao_operator.pao({{2, 8.5375}, {4, 8.5375}});

    SetTime(1538 + 210 - 100 - 198);
    SetPlantActiveTime(ICE_SHROOM, 298);
    ice_filler.coffee();

    SetTime(410);
    Card({{PUFF_SHROOM, 1, 8}, {SNOW_PEA, 2, 8}});
    SetTime(1538 + 10 - 266 - 147);
    Shovel({{1, 8}, {2, 8}});

    for (auto wave : {4, 5, 6, 7, 12, 13, 14, 15, 16, 17})
    {
        // I3PPDD-PP 1780 （w12 I3PPDDa-PP）
        SetTime(410 - 373, wave);
        pao_operator.pao({{2, 8.4625}, {4, 8.4625}});
        Delay(212);
        pao_operator.pao({{1, 8.4375}, {4, 8.4375}});
        SetTime(1580 - 373);
        pao_operator.pao({{2, 8.525}, {4, 8.525}});

        if (wave == 12)
        {
            SetTime(10);
            Card(SQUASH, 1, 9);
        }

        SetTime(1580 + 210 - 100 - 198);
        SetPlantActiveTime(ICE_SHROOM, 298);
        ice_filler.coffee();
    }

    for (auto wave : {8, 18})
    {
        // I3PPDD-PP 1916
        SetTime(410 - 373, wave);
        pao_operator.pao({{2, 8.6}, {4, 8.6}});
        Delay(212);
        pao_operator.pao({{1, 8.3125}, {4, 8.3125}});
        SetTime(1716 - 373);
        pao_operator.pao({{2, 8.4625}, {4, 8.4625}});

        SetTime(1716 + 210 - 100 - 198);
        SetPlantActiveTime(ICE_SHROOM, 298);
        ice_filler.coffee();
    }

    for (auto wave : {9, 19})
    {
        // I3PPDD-PPNDDd
        SetTime(410 - 373, wave);
        pao_operator.pao({{2, 8.6}, {4, 8.6}});
        Delay(212);
        pao_operator.pao({{1, 7.4125}, {4, 7.4125}});

        SetTime(1716 - 373);
        pao_operator.pao({{2, 8.4625}, {4, 8.4625}});
        SetTime(1716 + 253 - 100 - 198);
        SetPlantActiveTime(DOOM_SHROOM, 298);
        Card({{DOOM_SHROOM, 2, 8}, {COFFEE_BEAN, 2, 8}});
        SetTime(2095 - 373);
        pao_operator.pao({{1, 8.3}, {4, 8.3}});
        SetTime(1716 + 253 + 219 + 16 - 373);
        pao_operator.pao(3, 4);
    }

    SetTime(294 - 373, 10);
    // w10 A'Dd/PSd
    pao_operator.pao({{4, 9}, {4, 9}});
    Delay(107);
    pao_operator.pao(2, 8.5625);
    SetTime(294 + 262 - 373);
    pao_operator.pao(4, 2.75);
    SetTime(194);
    Card(JALAPENO, 2, 9);
    SetTime(401 + 262 - 373);
    pao_operator.pao(2, 3.75);

    SetTime(602 - 198 - 100);
    ice_filler.coffee();

    SetTime(178, 11);
    // w11 IPA-PP 1738
    Card(CHERRY_BOMB, 4, 8);
    SetTime(510 - 376);
    pao_operator.pao(2, 7.4125);
    SetTime(1538 - 373);
    pao_operator.pao({{2, 8.475}, {4, 8.475}});

    SetTime(1538 + 210 - 100 - 198);
    SetPlantActiveTime(ICE_SHROOM, 298);
    ice_filler.coffee();

    SetTime(-55, 20);
    pao_operator.pao({{2, 9}, {4, 9}, {2, 9}, {4, 9}, {2, 9}, {4, 9}});
    SetTime(394 - 373 + 3);
    pao_operator.pao({{3, 3}, {2, 8.5}, {4, 8.5}, {3, 6}});
    SetTime(5500 - 373);
    pao_operator.pao({{2, 8}, {4, 8}});
}